package com.hmall.api.interceptor;

import com.hmall.common.utils.UserContext;
import feign.Request;
import feign.RequestInterceptor;
import feign.RequestTemplate;
import org.aopalliance.intercept.Interceptor;

//拦截器
public class UserInfoInterceptor implements RequestInterceptor {
    @Override
    public void apply(RequestTemplate requestTemplate) {
        Long userId = UserContext.getUser();
        if (userId != null) {
            requestTemplate.header("user-info", userId.toString());
        }
    }
}
